package cn.ingrun.ingrunutils.responseUtil;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.MultiValueMap;

public class ResponseUtil extends ResponseEntity<ResponseModel> {

    public ResponseUtil (HttpStatus status) {
        super(status);
    }

    public ResponseUtil (ResponseModel body, HttpStatus status) {
        super(body, status);
    }

    public ResponseUtil (MultiValueMap<String, String> headers, HttpStatus status) {
        super(headers, status);
    }

    public ResponseUtil (ResponseModel body, MultiValueMap<String, String> headers, HttpStatus status) {
        super(body, headers, status);
    }

    public static ResponseUtil auto(boolean bool){
        if (bool){
            return ResponseUtil.success( "true", HttpStatus.OK);
        }
        return ResponseUtil.error("false", HttpStatus.OK);
    }

    public static ResponseUtil success(){
        return new ResponseUtil(HttpStatus.OK);
    }

    public static ResponseUtil success(HttpStatus httpStatus){
        return new ResponseUtil(httpStatus);
    }

    public static ResponseUtil success(int code, String message, Object data){
        return new ResponseUtil(new ResponseModel(code, message, data), HttpStatus.OK);
    }

    public static ResponseUtil success(ResponseModel responseJson){
        return new ResponseUtil(responseJson, HttpStatus.OK);
    }

    public static ResponseUtil success(int code, String message, Object data, HttpStatus httpStatus){
        return new ResponseUtil(new ResponseModel(code, message, data), httpStatus);
    }

    public static ResponseUtil success(String message){
        return new ResponseUtil(new ResponseModel(200, message, ""), HttpStatus.OK);
    }

    public static ResponseUtil success(Object date){
        return new ResponseUtil(new ResponseModel(200, "success", date), HttpStatus.OK);
    }

    public static ResponseUtil success(String message, Object date){
        return new ResponseUtil(new ResponseModel(200, message, date), HttpStatus.OK);
    }

    public static ResponseUtil error(int code, String message, Object data, HttpStatus httpStatus){
        return new ResponseUtil(new ResponseModel(code, message, data), httpStatus);
    }

    public static ResponseUtil error_404(){
        return new ResponseUtil(new ResponseModel(0, "未找到相关信息", ""), HttpStatus.NOT_FOUND);
    }

    public static ResponseUtil error(String message){
        return new ResponseUtil(new ResponseModel(0, message, ""), HttpStatus.BAD_REQUEST);
    }

    public static ResponseUtil error(String message, HttpStatus httpStatus){
        return new ResponseUtil(new ResponseModel(0, message, ""), httpStatus);
    }

    public static ResponseUtil error(ResponseModel responseJson, HttpStatus httpStatus){
        return new ResponseUtil(responseJson, httpStatus);
    }
    public static ResponseUtil error(ResponseModel responseJson){
        return new ResponseUtil(responseJson, HttpStatus.BAD_REQUEST);
    }


}
